home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 October / Macformat17.cdr / Shareware City / Developers / halma-111-c / Halma ƒ / Shell ƒ / graphics.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-11  |  16.7 KB  |  517 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        graphics.c
  4.  
  5. Purpose:    This module handles opening/closing/updating all windows:
  6.             this includes manipulating offscreen GWorlds & bitmaps
  7.             for fun and profit.
  8.  
  9. This program is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2 of the License, or
  12. (at your option) any later version.
  13.  
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with this program in a file named "GNU General Public License".
  21. If not, write to the Free Software Foundation, 675 Mass Ave,
  22. Cambridge, MA 02139, USA.
  23.  
  24. \**********************************************************************/
  25.  
  26. #include "graphics.h"
  27. #include "about.h"
  28. #include "about MSG.h"
  29. #include "help.h"
  30. #include "dialogs.h"
  31. #include "error.h"
  32. #include "menus.h"
  33. #include "environment.h"
  34. #include "prefs.h"
  35. #include "util.h"
  36. #include "program globals.h"
  37.  
  38. /* internal global variables for use by graphics.c only */
  39. static    ExtendedWindowDataHandle    gTheWindowData[NUM_WINDOWS];
  40. static    Rect        gBoundsRect[NUM_WINDOWS];        /* rectangle of offscreen bitmap */
  41. static    Rect        gMainScreenBounds;                /* bounds of main monitor */
  42. static    GWorldPtr    gTheGWorld[NUM_WINDOWS];        /* offscreen graphics world */
  43. static    Ptr            gBWBitMap[NUM_WINDOWS];            /* offscreen bitmap for B/W machines */
  44. static    GrafPort    gBWGrafPort[NUM_WINDOWS];        /* offscreen grafport "  "     "     */
  45. static    GrafPtr        gBWGrafPtr[NUM_WINDOWS];        /* offscreen grafptr  "  "     "     */
  46. static    GWorldPtr    currentGWorld;
  47. static    GDHandle    currentGDHandle;
  48.  
  49. Boolean InitTheGraphics(void)
  50. {
  51.     short            i,j;
  52.     
  53.     GetMainScreenBounds();
  54.     
  55.     for (i=0; i<NUM_WINDOWS; i++)
  56.     {
  57.         /* nothing is inited; if there's an error later on, we'll know how much to */
  58.         /* clean up in ShutDownTheGraphics() */
  59.         gTheGWorld[i]=(GWorldPtr)0L;
  60.         gTheWindowData[i]=(ExtendedWindowDataHandle)0L;
  61.     }
  62.     
  63.     for (i=0; i<NUM_WINDOWS; i++)
  64.     {
  65.         gTheWindowData[i]=(ExtendedWindowDataHandle)NewHandle(sizeof(ExtendedWindowDataRec));
  66.         if (gTheWindowData[i]==0L)                            /* return if error */
  67.             return FALSE;
  68.         
  69.         (**(gTheWindowData[i])).offscreenNeedsUpdate=TRUE;    /* offscreen not inited */
  70.         (**(gTheWindowData[i])).theWindowPtr=0L;            /* window ptr not inited */
  71.         (**(gTheWindowData[i])).windowIndex=i;                /* so we can retrieve it O(1) */
  72.         (**(gTheWindowData[i])).windowDepth=
  73.             (**(gTheWindowData[i])).maxDepth=1;                /* init at B/W */
  74.         (**(gTheWindowData[i])).isColor=FALSE;                /* init to grayscale */
  75.         for (j=0; j<MAX_TE_HANDLES; j++)
  76.             (**(gTheWindowData[i])).hTE[j]=0L;
  77.         HLockHi((Handle)gTheWindowData[i]);
  78.     }
  79.     
  80.     /* set window dispatch routines */
  81.     SetIndDispatchProc(kAbout, AboutBoxDispatch);
  82.     SetIndDispatchProc(kHelp, HelpWindowDispatch);
  83.     SetIndDispatchProc(kAboutMSG, AboutMSGBoxDispatch);
  84.     
  85.     /* call window dispatch routines with "startup" message */
  86.     CallIndDispatchProc(kAbout, kStartup, 0L);
  87.     CallIndDispatchProc(kHelp, kStartup, 0L);
  88.     CallIndDispatchProc(kAboutMSG, kStartup, 0L);
  89.     
  90.     return TRUE;
  91. }
  92.  
  93. void OpenTheIndWindow(short index)
  94. {
  95.     WindowPtr        theWindow;
  96.     
  97.     if (!((**gTheWindowData[index]).theWindowPtr))        /* if window exists, we'll just update it (see below) */
  98.     {
  99.         if (CallIndDispatchProc(index, kInitialize, 0L)==kFailure)
  100.         {        /* default is to center window on main screen */
  101.             (**(gTheWindowData[index])).initialTopLeft.h =
  102.                 gMainScreenBounds.left + (((gMainScreenBounds.right -
  103.                 gMainScreenBounds.left) - (**(gTheWindowData[index])).windowWidth) / 2);
  104.             (**(gTheWindowData[index])).initialTopLeft.v =
  105.                 gMainScreenBounds.top + (((gMainScreenBounds.bottom -
  106.                 gMainScreenBounds.top) - (**(gTheWindowData[index])).windowHeight) / 2);
  107.         }
  108.         
  109.         (**(gTheWindowData[index])).windowBounds.left=
  110.             (**(gTheWindowData[index])).initialTopLeft.h;
  111.         
  112.         (**(gTheWindowData[index])).windowBounds.top=
  113.             (**(gTheWindowData[index])).initialTopLeft.v;
  114.             
  115.         if (((**(gTheWindowData[index])).windowType==noGrowDocProc) ||
  116.             ((**(gTheWindowData[index])).windowType==documentProc) ||
  117.             ((**(gTheWindowData[index])).windowType==movableDBoxProc) ||
  118.             ((**(gTheWindowData[index])).windowType==zoomDocProc) ||
  119.             ((**(gTheWindowData[index])).windowType==zoomNoGrow) ||
  120.             ((**(gTheWindowData[index])).windowType==rDocProc))
  121.                 (**(gTheWindowData[index])).windowBounds.top += 9;    /* compensate for title */
  122.         
  123.         /* don't put window over menu bar */
  124.         if ((**(gTheWindowData[index])).windowBounds.top < GetMBarHeight()+1)
  125.             (**(gTheWindowData[index])).windowBounds.top = GetMBarHeight()+1;
  126.         
  127.         (**(gTheWindowData[index])).windowBounds.bottom =
  128.             (**(gTheWindowData[index])).windowBounds.top +
  129.             (**(gTheWindowData[index])).windowHeight;
  130.         
  131.         (**(gTheWindowData[index])).windowBounds.right =
  132.             (**(gTheWindowData[index])).windowBounds.left +
  133.             (**(gTheWindowData[index])).windowWidth;
  134.         
  135.         KillOffscreen(index);        /* kill offscreen bitmaps that are left over */
  136.         
  137.         if (gHasColorQD)
  138.         {
  139.             /* create the color window with our specs, see IM Essentials 4-79ff */
  140.             (**gTheWindowData[index]).theWindowPtr=
  141.                 NewCWindow(0L, &((**(gTheWindowData[index])).windowBounds),
  142.                 (**(gTheWindowData[index])).windowTitle, FALSE,
  143.                 (**(gTheWindowData[index])).windowType, (WindowPtr)-1L,
  144.                 (**(gTheWindowData[index])).hasCloseBox,
  145.                 (unsigned long)gTheWindowData[index]);
  146.         }
  147.         else
  148.         {
  149.             /* create the B/W window with our specs, see IM Essentials 4-82ff */
  150.             (**gTheWindowData[index]).theWindowPtr=
  151.                 NewWindow(0L, &((**(gTheWindowData[index])).windowBounds),
  152.                 (**(gTheWindowData[index])).windowTitle, FALSE,
  153.                 (**(gTheWindowData[index])).windowType, (WindowPtr)-1L,
  154.                 (**(gTheWindowData[index])).hasCloseBox,
  155.                 (unsigned long)gTheWindowData[index]);
  156.         }
  157.     }
  158.     
  159.     if ((theWindow=GetIndWindowGrafPtr(index))!=0L)
  160.     {
  161.         ShowWindow(theWindow);            /* immediately show this new window */
  162.         SelectWindow(theWindow);        /* immediately select this new window */
  163.         SetPort(theWindow);            /* important! for TE info to stick*/
  164.         /* call window's dispatch routine to alert it that it's open now */
  165.         CallIndDispatchProc(index, kOpen, 0L);
  166.         UpdateTheWindow((ExtendedWindowDataHandle)gTheWindowData[index]);    /* immediately update this new window */
  167.     }
  168.     else HandleError(kNoMemory, FALSE);            /* if unsuccessful, display error */
  169. }
  170.  
  171. void GetMainScreenBounds(void)
  172. {
  173.     gMainScreenBounds = screenBits.bounds;        /* low-mem global */
  174.     gMainScreenBounds.top += GetMBarHeight();    /* don't include menu bar */
  175. }
  176.  
  177. short GetBiggestDeviceDepth(WindowDataHandle theData)
  178. {
  179.     short            index;
  180.     Rect            tempRect;
  181.     long            biggestSize;
  182.     long            tempSize;
  183.     GDHandle        thisHandle, gBiggestDevice;
  184.     
  185.     if (!gHasColorQD)
  186.         return 1;
  187.     
  188.     index=(**theData).windowIndex;
  189.     
  190.     if (!GetIndWindowGrafPtr(index))
  191.         return (**(**GetMainDevice()).gdPMap).pixelSize;
  192.     
  193.     thisHandle = GetDeviceList();
  194.     gBiggestDevice = 0L;
  195.     biggestSize = 0L;
  196.     
  197.     while (thisHandle)
  198.     {
  199.         if (TestDeviceAttribute(thisHandle, screenDevice) &&
  200.             TestDeviceAttribute(thisHandle, screenActive))
  201.         {
  202.             if (SectRect(&(GetIndWindowGrafPtr(index)->portRect), &((**thisHandle).gdRect),
  203.                     &tempRect))
  204.             {
  205.                 if (biggestSize < (tempSize = ((long)(tempRect.bottom - tempRect.top))*
  206.                     ((long)(tempRect.right - tempRect.left))))
  207.                 {
  208.                     biggestSize = tempSize;
  209.                     gBiggestDevice = thisHandle;
  210.                 }
  211.             }
  212.         }
  213.         thisHandle = GetNextDevice(thisHandle);
  214.     }
  215.     
  216.     return (gBiggestDevice) ? (**(**gBiggestDevice).gdPMap).pixelSize : 1;
  217. }
  218.  
  219. short GetWindowDepth(WindowDataHandle theData)
  220. {
  221.     short            index;
  222.     
  223.     index=(**theData).windowIndex;
  224.     /* if Color Quickdraw is not available, the depth must be 1. */
  225.     /* if Color Quickdraw is available and the window exists, return the window's
  226.        GWorld's graphics device's pixel map's pixel depth */
  227.     /* if Color Quickdraw is available and the window does not exist, return the
  228.        pixel depth of the main screen */
  229.     return (gHasColorQD) ? ((GetIndWindowGrafPtr(index)) ?
  230.             (**(**(GetGWorldDevice(gTheGWorld[index]))).gdPMap).pixelSize :
  231.             (**(**GetMainDevice()).gdPMap).pixelSize) : 1;
  232. }
  233.  
  234. Boolean WindowIsColor(WindowDataHandle theData)
  235. {
  236.     short            index;
  237.     
  238.     index=(**theData).windowIndex;
  239.     return (gHasColorQD) ? ((GetWindowDepth(theData)>8) ? TRUE :
  240.         TestDeviceAttribute(GetGWorldDevice(gTheGWorld[index]), gdDevType)) : FALSE;
  241. }
  242.  
  243. void UpdateTheWindow(ExtendedWindowDataHandle theData)
  244. {
  245.     short            index;
  246.     long            offRowBytes, sizeOfOff;
  247.     unsigned long    updateResult;
  248.     Boolean            isColor;
  249.     
  250.     index=(**theData).windowIndex;
  251.     gBoundsRect[index]=GetIndWindowGrafPtr(index)->portRect;
  252.     OffsetRect(&gBoundsRect[index], -gBoundsRect[index].left, -gBoundsRect[index].top);
  253.  
  254.     if (gHasColorQD)    /* w/o Color Quickdraw, GWorlds may not be supported */
  255.     {
  256.         if (gTheGWorld[index]==0L)        /* create new graphics world if none exists */
  257.         {
  258.             /* try to create new graphics world; display error if unsuccessful */
  259.             if (NewGWorld(&gTheGWorld[index],
  260.                 (GetBiggestDeviceDepth(theData)>=(**theData).maxDepth) ?
  261.                 (**theData).maxDepth : 0, &gBoundsRect[index], 0L, 0L, 0)!=0)
  262.             {
  263.                 HandleError(kNoMemory, TRUE);        /* quits */
  264.             }
  265.             
  266.             (**theData).windowDepth=GetWindowDepth((WindowDataHandle)theData);
  267.             NoPurgePixels(GetGWorldPixMap(gTheGWorld[index]));    /* never purge our pixmap! */
  268.             updateResult=1;
  269.         }
  270.         else updateResult=0;
  271.         
  272.         GetGWorld(¤tGWorld, ¤tGDHandle);    /* get current settings */
  273.         LockPixels(GetGWorldPixMap(gTheGWorld[index]));    /* important!  copybits may move mem */
  274.         /* update offscreen graphics world, compensating for change in pixel depth */
  275.         updateResult|=(unsigned long)UpdateGWorld(&gTheGWorld[index],
  276.             (GetBiggestDeviceDepth(theData)>=(**theData).maxDepth) ? (**theData).maxDepth :
  277.             0, &gBoundsRect[index], 0L, 0L, 0);
  278.         SetGWorld(gTheGWorld[index], 0L);                /* set to our offscreen gworld */
  279.         
  280.         isColor=WindowIsColor(theData);
  281.         if (isColor!=(**theData).isColor)
  282.         {
  283.             (**theData).isColor=isColor;
  284.             updateResult=1;
  285.         }
  286.         
  287.         if ((updateResult!=0L) || ((**theData).windowDepth!=GetWindowDepth(theData)))
  288.         {
  289.             (**theData).windowDepth=GetWindowDepth((WindowDataHandle)theData);    /* save new depth */
  290.             (**theData).offscreenNeedsUpdate=TRUE;                /* we'll need to redraw */
  291.             CallDispatchProc(theData, kChangeDepth, 0L);
  292.         }
  293.     }
  294.     else    /* deal with (guaranteed) B/W bitmaps manually */
  295.     {
  296.         if (gBWGrafPtr[index]==0L)    /* create new offscreen bitmap if none exists */
  297.         {
  298.             gBWGrafPtr[index]=&gBWGrafPort[index];
  299.             OpenPort(gBWGrafPtr[index]);    /* make a new port */
  300.             
  301.             /* calculate the size of the offscreen bitmap from the boundsrect */
  302.             offRowBytes=(((gBoundsRect[index].right-gBoundsRect[index].left)+15)>>4)<<1;
  303.             sizeOfOff=(long)(gBoundsRect[index].bottom-gBoundsRect[index].top)*offRowBytes;
  304.             
  305.             gBWBitMap[index]=NewPtr(sizeOfOff);        /* allocate space for bitmap */
  306.             if (gBWBitMap[index]==0L)                /* abort if unsuccessful */
  307.             {
  308.                 ClosePort(gBWGrafPtr[index]);        /* cleaning up... */
  309.                 gBWGrafPtr[index]=0L;
  310.                 HandleError(kNoMemory, TRUE);        /* displaying error... */
  311.             }
  312.             
  313.             gBWGrafPort[index].portBits.baseAddr=gBWBitMap[index];    /* --> our bitmap */
  314.             gBWGrafPort[index].portBits.rowBytes=offRowBytes;        /* bitmap size */
  315.             gBWGrafPort[index].portBits.bounds=                        /* bitmap bounds */
  316.                 gBWGrafPort[index].portRect=gBoundsRect[index];
  317.             
  318.             SetPort(gBWGrafPtr[index]);
  319.             (**theData).offscreenNeedsUpdate=TRUE;
  320.         }
  321.         else SetPort(gBWGrafPtr[index]);            /* set port for subsequent drawing */
  322.     }    
  323.     
  324.     if ((**theData).offscreenNeedsUpdate)            /* if we need to redraw */
  325.     {
  326.         (**theData).offscreenNeedsUpdate=FALSE;        /* not anymore */
  327.         /* call window's dispatch and tell it to redraw itself */
  328.         CallDispatchProc(theData, kUpdate, GetWindowDepth((WindowDataHandle)theData));
  329.     }
  330.     
  331.     if (gHasColorQD)
  332.         SetGWorld(currentGWorld, currentGDHandle);    /* restore old settings */
  333.     
  334.     SetPort(GetWindowGrafPtr(theData));
  335.     
  336.     /* copy offscreen bitmap from graphics world or bitmap to onscreen window */
  337.     if (CallDispatchProc(theData, kCopybits, gHasColorQD ? (unsigned long)gTheGWorld[index] :
  338.         (unsigned long)gBWGrafPtr[index])==kFailure)
  339.         CopyBits(gHasColorQD ? &(((GrafPtr)gTheGWorld[index])->portBits) :
  340.                     &(gBWGrafPtr[index]->portBits), &(GetIndWindowGrafPtr(index)->portBits),
  341.                     &gBoundsRect[index], &gBoundsRect[index], 0, 0L);
  342.     
  343.     for (index=0; index<MAX_TE_HANDLES; index++)
  344.     {
  345.         if ((**theData).hTE[index]!=0L)
  346.             TEUpdate(&(GetIndWindowGrafPtr(index)->portRect), (**theData).hTE[index]);
  347.     }
  348.  
  349.     if (gHasColorQD)
  350.         UnlockPixels(GetGWorldPixMap(gTheGWorld[index]));    /* remember we locked these? */
  351.     
  352.     ValidRect(&(GetIndWindowGrafPtr(index)->portRect));        /* so we don't reupdate */
  353. }
  354.  
  355. Boolean CloseTheWindow(ExtendedWindowDataHandle theData)
  356. {
  357.     short            index;
  358.     
  359.     index=(**theData).windowIndex;
  360.     
  361.     /* if the window's dispatch cancels the close, abort */
  362.     if (CallDispatchProc((WindowDataHandle)theData, kClose, 0L)==kCancel)
  363.         return FALSE;
  364.     
  365.     DisposeWindow(GetIndWindowGrafPtr(index));    /* get rid of the actual window in memory */
  366.     (**gTheWindowData[index]).theWindowPtr=0L;    /* so _we_ know the window doesn't exist */
  367.     KillOffscreen(index);                /* kill offscreen bitmaps left over */
  368.     
  369.     /* tell window's dispatch that it's disposed of now */
  370.     CallDispatchProc((WindowDataHandle)theData, kDispose, 0L);
  371.     
  372.     return TRUE;    /* successful close */
  373. }
  374.  
  375. Boolean CloseTheIndWindow(short index)
  376. {
  377.     return CloseTheWindow(gTheWindowData[index]);
  378. }
  379.  
  380. PicHandle DrawThePicture(PicHandle thePict, short whichPict, short x, short y)
  381. /* a standard routine for loading a picture (if necessary) and then drawing it */
  382. {
  383.     Rect            temp;
  384.     
  385.     if (thePict==0L)        /* get it if it doesn't exist */
  386.         thePict=(PicHandle)GetPicture(whichPict);
  387.     
  388.     HLock((Handle)thePict);        /* lock it down for dereferencing to get picture bounds */
  389.     temp.top=y;
  390.     temp.left=x;
  391.     temp.bottom=temp.top+(**thePict).picFrame.bottom-(**thePict).picFrame.top;
  392.     temp.right=temp.left+(**thePict).picFrame.right-(**thePict).picFrame.left;
  393.     DrawPicture(thePict, &temp);    /* draw picture at (x,y) */
  394.     HUnlock((Handle)thePict);        /* unlock for better memory management */
  395.     return thePict;
  396. }
  397.  
  398. PicHandle ReleaseThePict(PicHandle thePict)
  399. {
  400.     if (thePict!=0L)    /* if exists, release it */
  401.         ReleaseResource((Handle)thePict);
  402.     return 0L;
  403. }
  404.  
  405. Boolean SetPortToOffscreen(WindowDataHandle theData)
  406. {
  407.     short            index;
  408.     
  409.     index=(**theData).windowIndex;
  410.     
  411.     if (gHasColorQD)
  412.     {
  413.         if (gTheGWorld[index]==0L)
  414.             return FALSE;
  415.         GetGWorld(¤tGWorld, ¤tGDHandle);    /* get current settings */
  416.         LockPixels(GetGWorldPixMap(gTheGWorld[index]));    /* important!  copybits may move mem */
  417.         SetGWorld(gTheGWorld[index], 0L);
  418.     }
  419.     else
  420.     {
  421.         if (gBWGrafPtr[index]==0L)
  422.             return FALSE;
  423.         SetPort(gBWGrafPtr[index]);
  424.     }
  425.     
  426.     return TRUE;
  427. }
  428.  
  429. void RestorePortToScreen(WindowDataHandle theData)
  430. {
  431.     if (gHasColorQD)
  432.     {
  433.         SetGWorld(currentGWorld, currentGDHandle);    /* restore old settings */
  434.         UnlockPixels(GetGWorldPixMap(gTheGWorld[(**theData).windowIndex]));
  435.     }
  436.     
  437.     SetPort(GetWindowGrafPtr(theData));
  438. }
  439.  
  440. GrafPtr GetOffscreenGrafPtr(WindowDataHandle theData)
  441. {
  442.     if (gHasColorQD)
  443.         return (GrafPtr)gTheGWorld[(**theData).windowIndex];
  444.     else
  445.         return gBWGrafPtr[(**theData).windowIndex];
  446. }
  447.  
  448. GrafPtr GetIndOffscreenGrafPtr(short index)
  449. {
  450.     return GetOffscreenGrafPtr(gTheWindowData[index]);
  451. }
  452.  
  453. GrafPtr GetWindowGrafPtr(WindowDataHandle theData)
  454. {
  455.     return (GrafPtr)((**theData).theWindowPtr);
  456. }
  457.  
  458. GrafPtr GetIndWindowGrafPtr(short index)
  459. {
  460.     return GetWindowGrafPtr(gTheWindowData[index]);
  461. }
  462.  
  463. WindowDataHandle GetIndWindowDataHandle(short index)
  464. {
  465.     return gTheWindowData[index];
  466. }
  467.  
  468. void SetIndDispatchProc(short index, ProcPtr theProc)
  469. {
  470.     (**gTheWindowData[index]).dispatchProc=theProc;
  471. }
  472.  
  473. short CallIndDispatchProc(short index, short theMessage, unsigned long misc)
  474. {
  475.     return ((**(gTheWindowData[index])).dispatchProc)((WindowDataHandle)gTheWindowData[index], theMessage, misc);
  476. }
  477.  
  478. short CallDispatchProc(ExtendedWindowDataHandle theData, short theMessage, unsigned long misc)
  479. {
  480.     return ((**theData).dispatchProc)((WindowDataHandle)theData, theMessage, misc);
  481. }
  482.  
  483. void SetIndWindowTitle(short index, Str255 theTitle)
  484. {
  485.     Mymemcpy((Ptr)((**(gTheWindowData[index])).windowTitle), (Ptr)theTitle, theTitle[0]+1);
  486. }
  487.  
  488. void KillOffscreen(short index)
  489. {
  490.     if (gTheGWorld[index]!=0L)
  491.         DisposeGWorld(gTheGWorld[index]);
  492.     if (gBWGrafPtr[index]!=0L)
  493.         DisposePtr((Ptr)gBWGrafPtr[index]);
  494.     gTheGWorld[index]=0L;
  495.     gBWGrafPtr[index]=0L;
  496.     (**(gTheWindowData[index])).offscreenNeedsUpdate=TRUE;
  497. }
  498.  
  499. void ShutDownTheGraphics(void)
  500. {
  501.     short            i;
  502.     
  503.     /* send shutdown messages to the shell's windows */
  504.     CallIndDispatchProc(kAbout, kShutdown, 0L);
  505.     CallIndDispatchProc(kHelp, kShutdown, 0L);
  506.     CallIndDispatchProc(kAboutMSG, kShutdown, 0L);
  507.     
  508.     for (i=0; i<NUM_WINDOWS; i++)
  509.     {
  510.         KillOffscreen(i);
  511.         if (GetIndWindowGrafPtr(i)!=0L)
  512.             DisposeWindow((**gTheWindowData[i]).theWindowPtr);
  513.         if (gTheWindowData[i]!=0L)
  514.             DisposeHandle((Handle)gTheWindowData[i]);
  515.     }
  516. }
  517.